]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
global: Add concept of "session type"
authorRay Strode <rstrode@redhat.com>
Tue, 21 Jun 2011 14:09:09 +0000 (10:09 -0400)
committerRay Strode <rstrode@redhat.com>
Sun, 28 Aug 2011 16:22:38 +0000 (12:22 -0400)
This commit introduces a "session type" for
gnome-shell.  It essentially defines what
mode of operation the shell runs in
(normal-in-a-users-session mode, or at-the-login-screen mode).

Note this commit only lays the groundwork.  Actually
looking at the key and appropriately differentiating
the UI will happen in subsequent commits.

https://bugzilla.gnome.org/show_bug.cgi?id=657082

src/main.c
src/shell-global-private.h
src/shell-global.c
src/shell-global.h

index 1b96a255f287977279648f75ce64e4561c2a8ed1..116f00f688be231a1b2ac48447c351126852aa73 100644 (file)
@@ -23,6 +23,7 @@
 #include <telepathy-glib/debug-sender.h>
 
 #include "shell-a11y.h"
+#include "shell-global.h"
 #include "shell-global-private.h"
 #include "shell-perf-log.h"
 #include "st.h"
@@ -32,6 +33,8 @@ extern GType gnome_shell_plugin_get_type (void);
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
 #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
 
+static gboolean is_gdm_mode = FALSE;
+
 static void
 shell_dbus_init (gboolean replace)
 {
@@ -466,6 +469,12 @@ GOptionEntry gnome_shell_options[] = {
     N_("Print version"),
     NULL
   },
+  {
+    "gdm-mode", 0, 0, G_OPTION_ARG_NONE,
+    &is_gdm_mode,
+    N_("Mode used by GDM for login screen"),
+    NULL
+  },
   { NULL }
 };
 
@@ -474,6 +483,7 @@ main (int argc, char **argv)
 {
   GOptionContext *ctx;
   GError *error = NULL;
+  ShellSessionType session_type;
   int ecode;
   TpDebugSender *sender;
 
@@ -540,7 +550,12 @@ main (int argc, char **argv)
   g_log_set_default_handler (default_log_handler, sender);
 
   /* Initialize the global object */
-  _shell_global_init (NULL);
+  if (is_gdm_mode)
+      session_type = SHELL_SESSION_GDM;
+  else
+      session_type = SHELL_SESSION_USER;
+
+  _shell_global_init ("session-type", session_type, NULL);
 
   ecode = meta_run ();
 
index f10dfb8f4d3e78a3f8faee0442ae1f304dacbf9f..a44b4dc43c668838e1b7714b77a21ce42feb3139 100644 (file)
@@ -16,6 +16,9 @@ GjsContext *_shell_global_get_gjs_context (ShellGlobal  *global);
 gboolean _shell_global_check_xdnd_event (ShellGlobal  *global,
                                          XEvent       *xev);
 
+void     _shell_global_set_session_type (ShellGlobal      *global,
+                                         ShellSessionType  session_type);
+
 /* Used for async screenshot grabbing */
 typedef struct _screenshot_data {
   ShellGlobal  *global;
index 7160c2d5ea9044c64e7d3bedf2e75b6ac3fb92c5..3334b524a7040e054e02486d667663d1176f252a 100644 (file)
@@ -56,6 +56,8 @@ struct _ShellGlobal {
   MetaScreen *meta_screen;
   GdkScreen *gdk_screen;
 
+  ShellSessionType session_type;
+
   /* We use this window to get a notification from GTK+ when
    * a widget in our process does a GTK+ grab.  See
    * http://bugzilla.gnome.org/show_bug.cgi?id=570641
@@ -90,6 +92,7 @@ struct _ShellGlobal {
 enum {
   PROP_0,
 
+  PROP_SESSION_TYPE,
   PROP_OVERLAY_GROUP,
   PROP_SCREEN,
   PROP_GDK_SCREEN,
@@ -135,7 +138,9 @@ shell_global_set_property(GObject         *object,
     case PROP_STAGE_INPUT_MODE:
       shell_global_set_stage_input_mode (global, g_value_get_enum (value));
       break;
-
+    case PROP_SESSION_TYPE:
+      global->session_type = g_value_get_enum (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -152,6 +157,9 @@ shell_global_get_property(GObject         *object,
 
   switch (prop_id)
     {
+    case PROP_SESSION_TYPE:
+      g_value_set_enum (value, shell_global_get_session_type (global));
+      break;
     case PROP_OVERLAY_GROUP:
       g_value_set_object (value, meta_get_overlay_group_for_screen (global->meta_screen));
       break;
@@ -330,6 +338,14 @@ shell_global_class_init (ShellGlobalClass *klass)
                     G_TYPE_STRING,
                     G_TYPE_STRING);
 
+  g_object_class_install_property (gobject_class,
+                                   PROP_SESSION_TYPE,
+                                   g_param_spec_enum ("session-type",
+                                                      "Session Type",
+                                                      "The type of session",
+                                                      SHELL_TYPE_SESSION_TYPE,
+                                                      SHELL_SESSION_USER,
+                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
   g_object_class_install_property (gobject_class,
                                    PROP_OVERLAY_GROUP,
                                    g_param_spec_object ("overlay-group",
@@ -1886,3 +1902,32 @@ shell_global_screenshot_window (ShellGlobal  *global,
 
   return status == CAIRO_STATUS_SUCCESS;
 }
+
+/**
+ * shell_global_get_session_type:
+ * @global: The #ShellGlobal.
+ *
+ * Gets the type of session gnome-shell provides.
+ *
+ * The type determines what UI elements are displayed,
+ * what keybindings work, and generally how the shell
+ * behaves.
+ *
+ * A session type of #SHELL_SESSION_USER means gnome-shell
+ * will enable the activities overview, status menu, run dialog,
+ * etc. This is the default.
+ *
+ * A session type of #SHELL_SESSION_GDM means gnome-shell
+ * will enable a login dialog and run in a more confined
+ * way. This type is suitable for the display manager.
+ *
+ * Returns the type of session gnome-shell is providing.
+ */
+ShellSessionType
+shell_global_get_session_type (ShellGlobal  *global)
+{
+  g_return_val_if_fail (SHELL_IS_GLOBAL (global),
+                        SHELL_SESSION_USER);
+
+  return global->session_type;
+}
index aa1941a6d63b865d0669fd8a5f52e5a0f207b9b9..4018f5fa351ca4d7123d614e838f64c54553b410 100644 (file)
@@ -142,7 +142,6 @@ void     shell_global_reexec_self               (ShellGlobal  *global);
 
 void     shell_global_launch_calendar_server    (ShellGlobal  *global);
 
-
 typedef void (*ShellGlobalScreenshotCallback)  (ShellGlobal *global, gboolean success);
 
 void    shell_global_screenshot_area           (ShellGlobal  *global,
@@ -160,6 +159,12 @@ gboolean shell_global_screenshot_window         (ShellGlobal  *global,
 void    shell_global_screenshot                (ShellGlobal  *global,
                                                 const char *filename,
                                                 ShellGlobalScreenshotCallback callback);
+typedef enum {
+  SHELL_SESSION_USER,
+  SHELL_SESSION_GDM
+} ShellSessionType;
+
+ShellSessionType shell_global_get_session_type  (ShellGlobal  *global);
 
 G_END_DECLS